package com.atguigu.stgy.admin.service.impl;

import com.atguigu.stgy.admin.service.GraphInfoService;
import com.atguigu.stgy.model.dto.ApartmentDTO;
import org.springframework.stereotype.Service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.stgy.model.entity.GraphInfo;
import com.atguigu.stgy.admin.mapper.GraphInfoMapper;
import org.springframework.util.CollectionUtils;

@Service
public class GraphInfoServiceImpl extends ServiceImpl<GraphInfoMapper, GraphInfo> implements GraphInfoService {

    @Override
    public void batchSaveGraphInfo(ApartmentDTO apartmentDTO, Long apartmentInfoId) {

        if (CollectionUtils.isEmpty(apartmentDTO.getGraphVoList())){
            return ;
        }
        apartmentDTO.getGraphVoList().forEach(graphInfo -> {
            graphInfo.setItemId(apartmentInfoId);
            graphInfo.setItemType((byte) 1);
        });
        this.saveBatch(apartmentDTO.getGraphVoList());
    }
}
